package com.api.gbhg.huangwm.cron;

import com.customization.commons.LogTool;
import weaver.conn.RecordSet;
import weaver.interfaces.schedule.BaseCronJob;

/**
 * @Author	Huangwm
 * @Date 2022-03-15
 * @Version 1.0
 * @description TODO 更新预算项目版本主表中的所属独立核算单位
 */
public class RelationSubCompanyAfter extends BaseCronJob {
    private LogTool logTool = new LogTool("/log/gbhg/huangwm/cron/RelationSubCompanyAfter",false);

    @Override
    public void execute() {
        String sql1 = "select uf_jingfei_version.requestid,workflow_bill.tablename from uf_jingfei_version\n" +
                "left join workflow_requestbase \n" +
                "on uf_jingfei_version.lcjlsqjlid=workflow_requestbase.requestid\n" +
                "left join workflow_base\n" +
                "on workflow_requestbase.workflowid=workflow_base.id\n" +
                "left join workflow_bill\n" +
                "on workflow_base.formid=workflow_bill.id";
        RecordSet rs1 = new RecordSet();
        RecordSet rs2 = new RecordSet();
        rs1.execute(sql1);
        while (rs1.next()){
            String requestid = rs1.getString("requestid");
            String tablename = rs1.getString("tablename");
            rs2.execute("update uf_jingfei_version set dlhsdw=(select convert(int,convert(varchar,szdlhsdw)) from "+tablename+" where requestid="+requestid+") where requestid="+requestid);
        }
    }
}
